| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | Static Public Member Functions | List of all members
nkGraphics::Camera Class Reference

Offers all controls to model a camera. More...

Inheritance diagram for nkGraphics::Camera:

## Public Member Functions
float | getNear () const
float | getFar () const
const Frustum & | getFrustum ()
nkMemory::StringView | getName () const
float | getFov () const
float | getOrthographicHeight () const
PROJECTION_TYPE | getProjectionType () const
float | getAspectRatio () const
bool | getAutoUpdateOnContextSwitch () const
bool | getHidden () const
const nkMaths::Matrix & | getViewMatrix () const
const nkMaths::Matrix & | getProjectionMatrix () const
nkMaths::Matrix | getViewProjMatrix () const
virtual void | setPositionRelative (const nkMaths::Vector &value) override
virtual void | setPositionAbsolute (const nkMaths::Vector &value) override
virtual void | translateRelative (const nkMaths::Vector &value) override
virtual void | translateAbsolute (const nkMaths::Vector &value) override
virtual void | setOrientationRelative (const nkMaths::Quaternion &value) override
virtual void | setOrientationAbsolute (const nkMaths::Quaternion &value) override
virtual void | rotateRelative (const nkMaths::Quaternion &value) override
virtual void | rotateAbsolute (const nkMaths::Quaternion &value) override
virtual void | setScaleRelative (const nkMaths::Vector &value) override
virtual void | setScaleAbsolute (const nkMaths::Vector &value) override
virtual void | applyScale (const nkMaths::Vector &value) override
void | setNear (float value)
void | setFar (float value)
void | setName (const nkMemory::StringView &name)
void | setFov (float radianValue)
void | setOrthographicHeight (float value)
void | setProjectionType (PROJECTION_TYPE value)
void | setAspectRatio (float widthOnHeight)
void | prepareForContext (RenderContext *context)
void | setAutoUpdateOnContextSwitch (bool value)
void | setHidden (bool value)
void | updateViewMatrix ()
void | updateProjectionMatrix ()
void | lookAt (const nkMaths::Vector &point, const nkMaths::Vector &enforcedUp=nkMaths::Vector(0, 0, 0, 0))
void | getNearPlanePoints (nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
void | getFarPlanePoints (nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
void | getFrustumCornersDirectionsWorld (nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
void | getFrustumCornersDirectionsView (nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkMaths::Vector | getDirectionAtPixelWorld (int x, int y, RenderContext *fromContext=nullptr)
nkMaths::Vector | getDirectionAtScreenCoordWorld (float x, float y)
nkMaths::Vector | getDirectionAtPixelView (int x, int y, RenderContext *fromContext=nullptr)
nkMaths::Vector | getDirectionAtScreenCoordView (float x, float y)
virtual void | exportClassToTree (nkExport::Node *rootNode) override
virtual void | importClassFromTree (nkExport::Node *rootNode) override
Public Member Functions inherited from nkGraphics::Node
virtual | ~Node ()
nkMaths::Vector | getPositionRelative () const
nkMaths::Vector | getPositionAbsolute ()
nkMaths::Quaternion | getOrientationRelative () const
nkMaths::Quaternion | getOrientationAbsolute ()
nkMaths::Vector | getScaleRelative () const
nkMaths::Vector | getScaleAbsolute ()
void | setRelativeTransform (const nkMaths::Matrix &value)
void | setAbsoluteTransform (const nkMaths::Matrix &value)
nkMaths::Matrix | getRelativeTransform ()
nkMaths::Matrix | getAbsoluteTransform ()
void | updateTransformations ()
void | dispatchDirtyTransform ()
nkMaths::Vector | getAbsoluteUp ()
nkMaths::Vector | getAbsoluteFront ()
nkMaths::Vector | getAbsoluteRight ()
void | setParentNode (Node *parent)
Node * | getParentNode () const
Node * | getChildNode (unsigned int index) const
unsigned int | getNumChildNode () const
void | setName (nkMemory::StringView value)
nkMemory::StringView | getName () const
bool | getHidden () const
void | setHidden (bool value)
void | addEntityToTrack (Entity *entity)
void | stopEntityTracking (Entity *entity)
unsigned int | getTrackedEntityCount () const
Entity * | getTrackedEntity (unsigned int index) const
void | registerListener (NodeChangeListener *listener)
void | unregisterListener (NodeChangeListener *listener)
Public Member Functions inherited from nkExport::Exportable
| Exportable () noexcept
virtual | ~Exportable ()

## Static Public Member Functions
static nkMemory::UniquePtr< Camera > | create (System *system=nullptr)
Static Public Member Functions inherited from nkGraphics::Node
static nkMemory::UniquePtr< Node > | create (System *system=nullptr)

## Detailed Description

Offers all controls to model a camera.

See CameraManager::createOrRetrieve() or Camera::create() for instantiation.

## Member Function Documentation

## ◆ getNear()

float nkGraphics::Camera::getNear | ( |  | ) | const

Returns
  Current near plane distance used.

## ◆ getFar()

float nkGraphics::Camera::getFar | ( |  | ) | const

Returns
  Current far plance distance used.

## ◆ getFrustum()

const Frustum& nkGraphics::Camera::getFrustum | ( |  | ) |

Returns
  The frustum representing the field of view of the camera.

## ◆ getName()

nkMemory::StringView nkGraphics::Camera::getName | ( |  | ) | const

Returns
  The camera's name.

## ◆ getFov()

float nkGraphics::Camera::getFov | ( |  | ) | const

Returns
  The vertical field of view of the camera, in radians.

## ◆ getOrthographicHeight()

float nkGraphics::Camera::getOrthographicHeight | ( |  | ) | const

Returns
  The orthographic height used by the camera, in world units.

## ◆ getProjectionType()

PROJECTION_TYPE nkGraphics::Camera::getProjectionType | ( |  | ) | const

Returns
  The projection type currently used by the camera.

## ◆ getAspectRatio()

float nkGraphics::Camera::getAspectRatio | ( |  | ) | const

Returns
  The currently used aspect ratio.

## ◆ getAutoUpdateOnContextSwitch()

bool nkGraphics::Camera::getAutoUpdateOnContextSwitch | ( |  | ) | const

Returns
  Whether the camera will auto update its aspect ratio before being used in a context (true) or not (false).

## ◆ getHidden()

bool nkGraphics::Camera::getHidden | ( |  | ) | const

Returns
  Whether the camera is hidden from project saving or not.

## ◆ getViewMatrix()

const nkMaths::Matrix& nkGraphics::Camera::getViewMatrix | ( |  | ) | const

Returns
  The current view matrix.

## ◆ getProjectionMatrix()

const nkMaths::Matrix& nkGraphics::Camera::getProjectionMatrix | ( |  | ) | const

Returns
  The current projection matrix.

## ◆ getViewProjMatrix()

nkMaths::Matrix nkGraphics::Camera::getViewProjMatrix | ( |  | ) | const

Returns
  The view * proj matrix.

## ◆ setPositionRelative()

virtual void nkGraphics::Camera::setPositionRelative | ( | const nkMaths::Vector & | value | ) |
| override virtual

See Node::setPositionRelative().

Reimplemented from nkGraphics::Node.

## ◆ setPositionAbsolute()

virtual void nkGraphics::Camera::setPositionAbsolute | ( | const nkMaths::Vector & | value | ) |
| override virtual

See Node::setPositionAbsolute().

Reimplemented from nkGraphics::Node.

## ◆ translateRelative()

virtual void nkGraphics::Camera::translateRelative | ( | const nkMaths::Vector & | value | ) |
| override virtual

See Node::translateRelative().

Reimplemented from nkGraphics::Node.

## ◆ translateAbsolute()

virtual void nkGraphics::Camera::translateAbsolute | ( | const nkMaths::Vector & | value | ) |
| override virtual

See Node::translateAbsolute().

Reimplemented from nkGraphics::Node.

## ◆ setOrientationRelative()

virtual void nkGraphics::Camera::setOrientationRelative | ( | const nkMaths::Quaternion & | value | ) |
| override virtual

See Node::setOrientationRelative().

Reimplemented from nkGraphics::Node.

## ◆ setOrientationAbsolute()

virtual void nkGraphics::Camera::setOrientationAbsolute | ( | const nkMaths::Quaternion & | value | ) |
| override virtual

See Node::setOrientationAbsolute().

Reimplemented from nkGraphics::Node.

## ◆ rotateRelative()

virtual void nkGraphics::Camera::rotateRelative | ( | const nkMaths::Quaternion & | value | ) |
| override virtual

See Node::rotateRelative().

Reimplemented from nkGraphics::Node.

## ◆ rotateAbsolute()

virtual void nkGraphics::Camera::rotateAbsolute | ( | const nkMaths::Quaternion & | value | ) |
| override virtual

See Node::rotateAbsolute().

Reimplemented from nkGraphics::Node.

## ◆ setScaleRelative()

virtual void nkGraphics::Camera::setScaleRelative | ( | const nkMaths::Vector & | value | ) |
| override virtual

See Node::setScaleRelative().

Reimplemented from nkGraphics::Node.

## ◆ setScaleAbsolute()

virtual void nkGraphics::Camera::setScaleAbsolute | ( | const nkMaths::Vector & | value | ) |
| override virtual

See Node::setScaleAbsolute().

Reimplemented from nkGraphics::Node.

## ◆ applyScale()

virtual void nkGraphics::Camera::applyScale | ( | const nkMaths::Vector & | value | ) |
| override virtual

See Node::applyScale().

Reimplemented from nkGraphics::Node.

## ◆ setNear()

void nkGraphics::Camera::setNear | ( | float | value | ) |

Sets the near plane distance value.

Parameters

  value | The near plane distance to assign.

Remarks
  This parameter is used for all projection types.

## ◆ setFar()

void nkGraphics::Camera::setFar | ( | float | value | ) |

Sets the far plane distance value.

Parameters

  value | The far plane distance to assign.

Remarks
  This parameter is used for all projection types.

## ◆ setName()

void nkGraphics::Camera::setName | ( | const nkMemory::StringView & | name | ) |

Sets the name of the camera.

Parameters

  name | The name to assign.

Remarks
  In theory, should never be called by external code.

## ◆ setFov()

void nkGraphics::Camera::setFov | ( | float | radianValue | ) |

Sets the vertical field of view.

Parameters

  radianValue | The vertical field of view, in radian.

Remarks
  This parameter is only relevant for the PERSPECTIVE projection type.

## ◆ setOrthographicHeight()

void nkGraphics::Camera::setOrthographicHeight | ( | float | value | ) |

Sets the orthographic height of the camera, in world units.

Parameters

  value | The height to use.

Remarks
  This parameter is only used with the ORTHOGRAPHIC projection type. Note that the orthographic width is derived from the aspect ratio (w = ratio * h).

## ◆ setProjectionType()

void nkGraphics::Camera::setProjectionType | ( | PROJECTION_TYPE | value | ) |

Sets the projection type to use.

Parameters

  value | The projection type the camera should use for creating its projection matrix.

## ◆ setAspectRatio()

void nkGraphics::Camera::setAspectRatio | ( | float | widthOnHeight | ) |

Sets the aspect ratio.

Parameters

  widthOnHeight | The ratio, given as width / height.

Remarks
  This parameter is used for all projection types.

## ◆ prepareForContext()

void nkGraphics::Camera::prepareForContext | ( | RenderContext * | context | ) |

Prepare the camera to be used by a render context. Will update values like the aspect ratio to be compatible with the rendering surface associated.

Parameters

  context | The context to adapt to.

## ◆ setAutoUpdateOnContextSwitch()

void nkGraphics::Camera::setAutoUpdateOnContextSwitch | ( | bool | value | ) |

Sets whether the camera should be updated for the context given before rendering. For instance, this will update the aspect ratio to fit the dimension of the render target.

Parameters

  value | Whether the camera should be updated (true) or not (false) when a context switch is done.

Remarks
  This can be useful when using a camera to render a scene on different windows / textures, for instance. In case rendering has to take specific aspect ratio for any purpose, this flag can remain off.

## ◆ setHidden()

void nkGraphics::Camera::setHidden | ( | bool | value | ) |

Sets whether the camera is hidden from project exporting. If enabled, the camera won't be exported in the decl files of the project. This can be useful when a camera is created programmatically in an application, and should not be duplicated in the declaration files.

Parameters

  value | If the camera should be hidden (true) or not (false).

## ◆ updateViewMatrix()

void nkGraphics::Camera::updateViewMatrix | ( |  | ) |

Updates the view matrix after new changes in parameters occurred.

## ◆ updateProjectionMatrix()

void nkGraphics::Camera::updateProjectionMatrix | ( |  | ) |

Updates the projection matrix after new changes in parameters occurred.

## ◆ lookAt()

void nkGraphics::Camera::lookAt | ( | const nkMaths::Vector & | point,
|  | const nkMaths::Vector & | enforcedUp = `nkMaths::Vector(0, 0, 0, 0)`
| ) |  |

Sets the camera to look at a coordinate.

Parameters

  point | The point to look at.
  enforcedUp | The up direction to take. If left blank, an automatic up is computed.

## ◆ getNearPlanePoints()

void nkGraphics::Camera::getNearPlanePoints | ( | nkMaths::Vector & | a,
|  | nkMaths::Vector & | b,
|  | nkMaths::Vector & | c,
|  | nkMaths::Vector & | d
| ) |  |

Fills up the 4 points of the near plane.

Parameters

  a | The first point.
  b | The second point.
  c | The third point.
  d | The fourth point.

## ◆ getFarPlanePoints()

void nkGraphics::Camera::getFarPlanePoints | ( | nkMaths::Vector & | a,
|  | nkMaths::Vector & | b,
|  | nkMaths::Vector & | c,
|  | nkMaths::Vector & | d
| ) |  |

Fills up the 4 points of the far plane.

Parameters

  a | The first point.
  b | The second point.
  c | The third point.
  d | The fourth point.

## ◆ getFrustumCornersDirectionsWorld()

void nkGraphics::Camera::getFrustumCornersDirectionsWorld | ( | nkMaths::Vector & | a,
|  | nkMaths::Vector & | b,
|  | nkMaths::Vector & | c,
|  | nkMaths::Vector & | d
| ) |  |

Fills up the directions of the frustum corners, in world space. Can be seen as the directions from the near plane points, to their attached far plane points.

Parameters

  a | The first direction.
  b | The second direction.
  c | The third direction.
  d | The fourth direction.

## ◆ getFrustumCornersDirectionsView()

void nkGraphics::Camera::getFrustumCornersDirectionsView | ( | nkMaths::Vector & | a,
|  | nkMaths::Vector & | b,
|  | nkMaths::Vector & | c,
|  | nkMaths::Vector & | d
| ) |  |

Fills up the directions of the frustum corners, in view space. Can be seen as the directions from the near plane points, to their attached far plane points.

Parameters

  a | The first direction.
  b | The second direction.
  c | The third direction.
  d | The fourth direction.

## ◆ getDirectionAtPixelWorld()

nkMaths::Vector nkGraphics::Camera::getDirectionAtPixelWorld | ( | int | x,
|  | int | y,
|  | RenderContext * | fromContext = `nullptr`
| ) |  |

Returns the direction, in world space, for one pixel.

Parameters

  x | The x coordinate of the pixel.
  y | The y coordinate of the pixel.
  fromContext | The context from which the pixel size should be retrieved. If left nullptr, the active context will be queried.

Returns
  The direction of the pixel, in world space.

Remarks
  If a context is given, it will be used to deduce the relative coordinates to sample from. Note that no change in ratio or projection matrix will take place for the given context.

## ◆ getDirectionAtScreenCoordWorld()

nkMaths::Vector nkGraphics::Camera::getDirectionAtScreenCoordWorld | ( | float | x,
|  | float | y
| ) |  |

Returns the direction, in world space, for a given position on screen.

Parameters

  x | The x coordinate, in [0, 1].
  y | The y coordinate, in [0, 1].

Returns
  The direction on screen, in world space.

## ◆ getDirectionAtPixelView()

nkMaths::Vector nkGraphics::Camera::getDirectionAtPixelView | ( | int | x,
|  | int | y,
|  | RenderContext * | fromContext = `nullptr`
| ) |  |

Returns the direction, in view space, for one pixel.

Parameters

  x | The x coordinate of the pixel.
  y | The y coordinate of the pixel.
  fromContext | The context from which the pixel size should be retrieved. If left nullptr, the active context will be queried.

Returns
  The direction of the pixel, in view space.

Remarks
  If a context is given, it will be used to deduce the relative coordinates to sample from. Note that no change in ratio or projection matrix will take place for the given context.

## ◆ getDirectionAtScreenCoordView()

nkMaths::Vector nkGraphics::Camera::getDirectionAtScreenCoordView | ( | float | x,
|  | float | y
| ) |  |

Returns the direction, in view space, for a given position on screen. , in [

Parameters

  x | The x coordinate0, 1].
  y | The y coordinate, in [0, 1].

Returns
  The direction on screen, in view space.

## ◆ exportClassToTree()

virtual void nkGraphics::Camera::exportClassToTree | ( | nkExport::Node * | rootNode | ) |
| override virtual

Exports an item into a tree describing its structure and its data.

Parameters

  rootNode | The node into which the object has to write its related information.

Reimplemented from nkGraphics::Node.

## ◆ importClassFromTree()

virtual void nkGraphics::Camera::importClassFromTree | ( | nkExport::Node * | rootNode | ) |
| override virtual

Imports information from a tree which is supposed to describe its structure and data.

Parameters

  rootNode | The root node of the tree holding the information.

Reimplemented from nkGraphics::Node.

## ◆ create()

static nkMemory::UniquePtr<Camera> nkGraphics::Camera::create | ( | System * | system = `nullptr` | ) |
| static

Creates a standalone resource, linking it to a system, but no manager. This method can be used to allocate a resource and manually manage its lifetime.

Parameters

  system | The system to create the resource into. If left to nullptr, then the Singleton instance will be used.

Returns
  The created resource instance.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsGraphics/Cameras/Camera.h